package com.jeasonzhao.report.engine.impl;

import com.jeasonzhao.report.engine.irp.IResourceLoader;

public abstract class AbstractLoader implements IResourceLoader
{
    private boolean m_isCaseSenstive = false;
    private java.util.Hashtable<String,String> hash = new java.util.Hashtable<String,String>();
    public void addProperty(String key,String value)
    {
        if(null == key || null == value)
        {
            return;
        }
        if(this.m_isCaseSenstive)
        {
            key = key.toLowerCase();
        }
        hash.put(key,value);
    }

    protected String getProperties(String ...key)
    {
        for(int n = 0;null != key && n < key.length;n++)
        {
            String s = __getProperties(key[n]);
            if(null != s)
            {
                return s;
            }
        }
        return null;
    }

    private String __getProperties(String key)
    {
        if(null == key)
        {
            return null;
        }
        else
        {
            if(this.m_isCaseSenstive)
            {
                key = key.toLowerCase();
            }
            return hash.get(key);
        }
    }

    public AbstractLoader()
    {
        this(false);
    }

    public AbstractLoader(boolean isCaseSenstive)
    {
        this.m_isCaseSenstive = isCaseSenstive;
    }
}
